<template>
    <div class="box">
        <el-row>
            <el-col :span="24">
                <div class="header">
                    <el-form ref="form" :model="form" label-width="80px" class="flex">
                        <el-form-item label="所属网点">
                            <el-select v-model="form.networkNameId" placeholder="请选择活动区域" style="width:286px">
                                <el-option v-for="item in networkList" :key="item.id" :label="item.networkName"
                                    :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="配置名称" style="margin-left: 10px;">
                            <el-input v-model="form.name" placeholder="请输入配置名称" style="width:286px"></el-input>
                        </el-form-item>
                        <el-form-item label="拉均对象" style="margin-left: 10px;">
                            <el-select v-model="form.pullUniformObject" placeholder="请选择活动区域" style="width:286px">
                                <el-option label="客户" value="客户"></el-option>
                                <el-option label="承包区" value="承包区"></el-option>
                                <el-option label="业务员" value="业务员"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="search">查询</el-button>
                            <el-button @click="clear">重置</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </el-col>
        </el-row>
        <el-row type="flex" justify="space-between">
            <el-col :span="6">
                <div>
                    当前页共10项
                </div>
            </el-col>
            <el-col :span="2">
                <div>
                    <el-button type="primary" >新增</el-button>
                </div>
            </el-col>
        </el-row>
        <el-row type="flex" justify="space-between">
            <el-col :span="24">
                <el-table :cell-style="{ textAlign: 'center' }" :header-cell-style="{ textAlign: 'center' }"
                    :data="tableData" border style="width: 100%">
                    <el-table-column prop="networkName.networkName" label="所属网点" width="240">
                    </el-table-column>
                    <el-table-column prop="name" label="名称" width="120">
                    </el-table-column>
                    <el-table-column prop="status" label="状态" width="300">
                        <template slot-scope="scope">
                            {{ scope.row.status == 1 ? "正常" : "禁止" }}
                        </template>
                         </el-table-column>

                        <el-table-column prop="pullUniformObject" label="拉均对象" width="120">
                        </el-table-column>
                        <el-table-column prop="pullUniformDimensionality" label="拉均维度" width="120">
                        </el-table-column>
                        <el-table-column prop="weightSection" label="重量段(kg)" width="120">
                        </el-table-column>
                        <el-table-column prop="excludedProvince" label="排除省份" width="120">
                        </el-table-column>
                        <el-table-column prop="transportType" label="运输方式" width="120">
                        </el-table-column>
                        <el-table-column prop="createBy" label="创建人" width="120">
                        </el-table-column>
                        <el-table-column prop="createTime" label="创建时间" width="120">
                        </el-table-column>
                        <el-table-column prop="updateBy" label="修改人" width="120">
                        </el-table-column>
                        <el-table-column prop="updateTime" label="修改时间" width="120">
                        </el-table-column>
                        <el-table-column fixed="right" label="操作" width="500">
                            <template slot-scope="scope">
                                <el-button type="text" size="small">查看客户</el-button>
                                <el-button type="text" size="small">个性化计泡</el-button>
                                <el-button type="text" size="small">个性化结算重量</el-button>
                            </template>
                        </el-table-column>
                </el-table>
            </el-col>
        </el-row>
        <div class="block" style="display: flex; justify-content: end;">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100"
                layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import { getOutletsList, getpullEvenList,pullEvenSearch } from "@/api/dashboard";

export default {
    data() {
        return {
            form: {
                networkNameId: '',
                pullUniformObject: '',
                name: '',
            },
            //网点列表
            networkList: [],
            pages: {
                pageNum: 1,
                pageSize: 10,
            },
            total: 0,
            currentPage4: 4,
            tableData: [],

        };
    },
    created() {
        this.getList()
        this.getOutLet()
    },
    methods: {
        // 获取网点列表
        getOutLet() {
            getOutletsList().then((res) => {
                if (res.code == 200) {
                    this.networkList = res.data
                }

            })
        },
        // 显示表格数据
        getList() {
            getpullEvenList().then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.data
                    this.total = res.data.total
                    this.pages = res.data.pages
                } else {
                    this.$message({
                        message: res.msg,
                        type: 'warning'
                    });
                }

            })
        },
        // 查询
        search() {
            pullEvenSearch(this.form).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.data
                    this.total = res.data.total
                    this.pages = res.data.pages
                } else {
                    this.$message({
                        message: res.msg,
                        type: 'warning'
                    });
                }

            })
        },
        // 重置
        clear() {
            this.form = {}
        },
        handleSizeChange(val) {
            this.pages.pageSize = val
            this.getList()

            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            this.pages.pageNum = val
            this.getList()
            console.log(`当前页: ${val}`);
        }

    },

}
</script>

<style lang="scss" scoped>
.box {
    padding: 20px;
}

.flex {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}

.header {
    padding-bottom: 20px;
    border-bottom: 1px solid #ccc;
}

.el-row {
    margin-bottom: 20px;

    &:last-child {
        margin-bottom: 0;
    }
}

.el-col {
    border-radius: 4px;
}

.bg-purple-dark {
    background: #99a9bf;
}

.bg-purple {
    background: #d3dce6;
}

.bg-purple-light {
    background: #e5e9f2;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
}

.row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
}
</style>